home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / MPW Interfaces & Libraries / AIncludes / MIDI.a < prev    next >
Encoding:
Text File  |  1992-01-29  |  11.2 KB  |  479 lines  |  [TEXT/MPS ]

  1. ; Version: 3.02
  2. ; Created: Friday, October 20, 1989 at 9:31:29 PM
  3.  
  4. ;;;
  5. ;;; MIDI.a
  6. ;;;
  7. ;;; This file contains the assembly-language interface for the MIDI Manager.
  8. ;;;
  9. ;;; Copyright © 1988-1991, Apple Computer, Inc.
  10. ;;; All Rights Reserved
  11. ;;;
  12.  
  13.     IF &TYPE('__IncludingMIDI__') = 'UNDEFINED' THEN
  14. __IncludingMIDI__    SET    1
  15.  
  16.     IF &TYPE('__IncludingTraps__') = 'UNDEFINED' THEN
  17.     INCLUDE 'Traps.a'
  18.     ENDIF
  19.  
  20.  
  21. ;;; _______________________________________________________________________________
  22. ;;;
  23. ;;;  Constants:
  24. ;;;
  25.  
  26. midiToolNum       EQU         4                         ; tool number of MIDI Mgr for SndDispVersion call.
  27. midiMaxNameLen    EQU         31                        ; maximum number of characters in port and client names
  28.  
  29.  
  30. ; Time formats
  31.  
  32. midiFormatMSec    EQU         0                         ; milliseconds
  33. midiFormatBeats   EQU         1                         ; beats
  34. midiFormat24fpsBit EQU        2                         ; 24 frames/sec.
  35. midiFormat25fpsBit EQU        3                         ; 25 frames/sec.
  36. midiFormat30fpsDBit EQU       4                         ; 30 frames/sec. drop-frame
  37. midiFormat30fpsBit EQU        5                         ; 30 frames/sec.
  38. midiFormat24fpsQF EQU         6                         ; 24 frames/sec. longInt format
  39. midiFormat25fpsQF EQU         7                         ; 25 frames/sec. longInt format
  40. midiFormat30fpsDQF EQU        8                         ; 30 frames/sec. drop-frame longInt format
  41. midiFormat30fpsQF EQU         9                         ; 30 frames/sec. longInt format
  42. midiInternalSync  EQU         0                         ; internally synced
  43. midiExternalSync  EQU         1                         ; externally synced
  44.  
  45.  
  46. ; Port types
  47.  
  48. midiPortTypeTime  EQU         0                         ; time port
  49. midiPortTypeInput EQU         1                         ; input port
  50. midiPortTypeOutput EQU        2                         ; output port
  51. midiPortTypeTimeInv EQU       3                         ; invisible time port
  52.  
  53.  
  54. ; OffsetTimes
  55.  
  56. midiGetEverything EQU         $7FFFFFFF                 ; get all packets, regardless of time stamps
  57. midiGetNothing    EQU         $80000000                 ; get no packets, regardless of time stamps
  58. midiGetCurrent    EQU         $00000000                 ; get current packets only
  59.  
  60.  
  61.  
  62. ;;;
  63. ;;; MIDI data and messages are passed in MIDIPacket records (see below).
  64. ;;; The first byte of every MIDIPacket contains a set of flags
  65. ;;;
  66. ;;; bits 0-1   00 = new MIDIPacket, not continued
  67. ;;;                01 = begining of continued MIDIPacket
  68. ;;;                10 = end of continued MIDIPacket
  69. ;;;                11 = continuation
  70. ;;; bits 2-3            reserved
  71. ;;;
  72. ;;;bits 4-6  000 = MIDIPacket contains MIDI data
  73. ;;;               001 = MIDIPacket contains MIDI Manager message
  74. ;;;
  75. ;;;  bit 7            0 = MIDIPacket has valid stamp
  76. ;;;                   1 = stamp with current clock
  77. ;;;
  78.  
  79. midiContMask      EQU         $03
  80. midiNoCont        EQU         $00
  81. midiStartCont     EQU         $01
  82. midiMidCont       EQU         $03
  83. midiEndCont       EQU         $02
  84. midiTypeMask      EQU         $70
  85. midiMsgType       EQU         $00
  86. midiMgrType       EQU         $10
  87. midiTimeStampMask EQU         $80
  88. midiTimeStampCurrent EQU      $80
  89. midiTimeStampValid EQU        $00
  90.  
  91.  
  92. ;  MIDI Manager MIDIPacket command words (the first word in the data field
  93. ;  for midiMgrType messages)
  94.  
  95. midiOverflowErr   EQU         $0001
  96. midiSCCErr        EQU         $0002
  97. midiPacketErr     EQU         $0003
  98. midiMaxErr        EQU         $00FF                     ; all command words less than this value
  99. ;    are error indicators
  100.  
  101. ;;; _______________________________________________________________________________
  102. ;;;
  103. ;;;  valid results to be returned from readHooks
  104. ;;;
  105.  
  106. midiKeepPacket    EQU         0
  107. midiMorePacket    EQU         1
  108. midiNoMorePacket  EQU         2
  109.  
  110.  
  111. ;;; _______________________________________________________________________________
  112. ;;;
  113. ;;;  Errors:
  114. ;;;
  115.  
  116. midiNoClientErr   EQU         -250                      ; no client with that ID found
  117. midiNoPortErr     EQU         -251                      ; no port with that ID found
  118. midiTooManyPortsErr EQU       -252                      ; too many ports already installed in the system
  119. midiTooManyConsErr EQU        -253                      ; too many connections made
  120. midiVConnectErr   EQU         -254                      ; pending virtual connection created
  121. midiVConnectMade  EQU         -255                      ; pending virtual connection resolved
  122. midiVConnectRmvd  EQU         -256                      ; pending virtual connection removed
  123. midiNoConErr      EQU         -257                      ; no connection exists between specified ports
  124. midiWriteErr      EQU         -258                      ; MIDIWritePacket couldn't write to all connected ports
  125. midiNameLenErr    EQU         -259                      ; name supplied is longer than 31 characters
  126. midiDupIDErr      EQU         -260                      ; duplicate client ID
  127. midiInvalidCmdErr EQU         -261                      ; command not supported for port type
  128.  
  129.  
  130. ;;; _______________________________________________________________________________
  131. ;;;
  132. ;;;  Driver calls:
  133. ;;;
  134.  
  135. midiOpenDriver    EQU         1
  136. midiCloseDriver   EQU         2
  137.  
  138.  
  139.  
  140. ;;; ________________________________________________________________________________
  141. ;;;
  142. ;;;  MIDI data and other messages are read and written in packets:
  143. ;;;
  144.  
  145. MIDIPacket        RECORD      0
  146. flags             DS.B        1
  147. len               DS.B        1
  148. tStamp            DS.L        1
  149. data              EQU         *
  150.                   ENDR
  151.  
  152.  
  153. ;;; _______________________________________________________________________________
  154. ;;;
  155. ;;;  port information
  156. ;;;
  157.  
  158. MIDIIDRec         RECORD      0
  159. clientID          DS.L        1
  160. portID            DS.L        1
  161.                   ENDR
  162.  
  163. MIDIPortParams    RECORD      0
  164. portID            DS.L        1                         ; ID of port, unique within client
  165. portType          DS.W        1                         ; Type of port - input, output, time, etc.
  166. timeBase          DS.W        1                         ; refnum of time base, 0 if none
  167. offsetTime        DS.L        1                         ; offset for current time stamps
  168. readHook          DS.L        1                         ; routine to call when input data is valid
  169. refCon            DS.L        1                         ; refcon for port (for client use)
  170. sync              DS.W        1                         ; internal, external,other
  171. curTime           DS.L        1                         ; current local time for the port
  172. format            DS.W        1                         ; time code format in use
  173. name              DS.B        256                       ; name of the port. This is a real live string, not a ptr.
  174.  
  175. size              EQU         *                         ; size of port params
  176.                   ENDR
  177.  
  178. MIDIPortInfo      RECORD      0
  179. portType          DS.W        1                         ; type of port
  180. timeBase          DS.L        2                         ; MIDIIDRec for time base
  181. numConnects       DS.W        1                         ; number of connections
  182. cList             EQU         *                         ; ARRAY [1..numConnects] of MIDIIDRec
  183.                   ENDR
  184.  
  185.  
  186. ;;; _______________________________________________________________________________
  187. ;;;
  188. ;;; Clocks:
  189. ;;;
  190.  
  191. MIDIClkInfo       RECORD      0
  192. sync              DS.W        1                         ; 0 = internal,  1 = external
  193. curTime           DS.L        1                         ; current value of port's clock
  194. format            DS.W        1                         ; time code format
  195. size              EQU         *                         ; size of MIDIClkInfo
  196.                   ENDR
  197.  
  198.  
  199. ;;; _______________________________________________________________________________
  200. ;;;
  201. ;;;  Equates for function selectors
  202. ;;;
  203.  
  204. midiVersion       EQU         0
  205. midiSignIn        EQU         4
  206. midiSignOut       EQU         8
  207. midiGetClients    EQU         12
  208. midiGetClientName EQU         16
  209. midiSetClientName EQU         20
  210. midiGetPorts      EQU         24
  211. midiAddPort       EQU         28
  212. midiGetPortInfo   EQU         32
  213. midiConnectData   EQU         36
  214. midiUnConnectData EQU         40
  215. midiConnectTime   EQU         44
  216. midiUnConnectTime EQU         48
  217. midiFlush         EQU         52
  218. midiGetReadHook   EQU         56
  219. midiSetReadHook   EQU         60
  220. midiGetPortName   EQU         64
  221. midiSetPortName   EQU         68
  222. midiWakeUp        EQU         72
  223. midiRemovePort    EQU         76
  224. midiGetSync       EQU         80
  225. midiSetSync       EQU         84
  226. midiGetCurTime    EQU         88
  227. midiSetCurTime    EQU         92
  228. midiStartTime     EQU         96
  229. midiStopTime      EQU         100
  230. midiPoll          EQU         104
  231. midiWritePacket   EQU         108
  232. midiWorldChanged  EQU         112
  233. midiGetOffsetTime EQU         116
  234. midiSetOffsetTime EQU         120
  235. midiConvertTime   EQU         124
  236. midiGetRefCon     EQU         128
  237. midiSetRefCon     EQU         132
  238. midiGetClRefCon   EQU         136
  239. midiSetClRefCon   EQU         140
  240. midiGetTCFormat   EQU         144
  241. midiSetTCFormat   EQU         148
  242. midiSetRunRate    EQU         152
  243. midiGetClientIcon EQU         156
  244.  
  245.  
  246. ;;; ________________________________________________________________________________
  247. ;;;
  248. ;;; Call Macros for Assembly
  249. ;;;
  250.  
  251.                                                         ;;
  252.                                                         ;;    fake _SndDispVersion which calls glue to make sure that the sound
  253.                                                         ;;    dispatcher has been installed
  254.                                                         ;;
  255.                   IMPORT      SndDispVersion
  256.  
  257.                   MACRO
  258. &label            _SndDispVersion
  259. &label            JSR         SndDispVersion    
  260.                                                         ; call the sound dispatcher glue in MIDIGlue.o
  261.                   ENDM
  262.  
  263.  
  264.                   MACRO
  265. &label            _CallMIDIMgr &selector
  266. &label            MOVE.L      #(&selector<<16)+midiToolNum,D0
  267.                   _SoundDispatch
  268.                   ENDM
  269.  
  270.  
  271.                   MACRO
  272. &label            _MIDISignIn
  273. &label            _CallMIDIMgr midiSignIn
  274.                   MEND
  275.  
  276.                   MACRO
  277. &label            _MIDISignOut
  278. &label            _CallMIDIMgr midiSignOut
  279.                   MEND
  280.  
  281.                   MACRO
  282. &label            _MIDIVersion
  283. &label            _CallMIDIMgr midiVersion
  284.                   MEND
  285.  
  286.                   MACRO
  287. &label            _MIDIGetClients
  288. &label            _CallMIDIMgr midiGetClients
  289.                   MEND
  290.  
  291.                   MACRO
  292. &label            _MIDIGetClientName
  293. &label            _CallMIDIMgr midiGetClientName
  294.                   MEND
  295.  
  296.                   MACRO
  297. &label            _MIDISetClientName
  298. &label            _CallMIDIMgr midiSetClientName
  299.                   MEND
  300.  
  301.                   MACRO
  302. &label            _MIDIGetPorts
  303. &label            _CallMIDIMgr midiGetPorts
  304.                   MEND
  305.                 
  306.                   MACRO
  307. &label            _MIDIAddPort
  308. &label            _CallMIDIMgr midiAddPort
  309.                   MEND
  310.  
  311.  
  312.                   MACRO
  313. &label            _MIDIGetPortInfo
  314. &label            _CallMIDIMgr midiGetPortInfo
  315.                   MEND
  316.  
  317.                   MACRO
  318. &label            _MIDIConnectData
  319. &label            _CallMIDIMgr midiConnectData
  320.                   MEND
  321.  
  322.  
  323.                   MACRO
  324. &label            _MIDIUnConnectData
  325. &label            _CallMIDIMgr midiUnConnectData
  326.                   MEND
  327.  
  328.                   MACRO
  329. &label            _MIDIConnectTime
  330. &label            _CallMIDIMgr midiConnectTime
  331.                   MEND
  332.  
  333.                   MACRO
  334. &label            _MIDIUnConnectTime
  335. &label            _CallMIDIMgr midiUnConnectTime
  336.                   MEND
  337.  
  338.                   MACRO
  339. &label            _MIDIFlush
  340. &label            _CallMIDIMgr midiFlush
  341.                   MEND
  342.  
  343.                   MACRO
  344. &label            _MIDIGetReadHook
  345. &label            _CallMIDIMgr midiGetReadHook
  346.                   MEND
  347.  
  348.                   MACRO
  349. &label            _MIDISetReadHook
  350. &label            _CallMIDIMgr midiSetReadHook
  351.                   MEND
  352.  
  353.                   MACRO
  354. &label            _MIDIGetPortName
  355. &label            _CallMIDIMgr midiGetPortName
  356.                   MEND
  357.  
  358.                   MACRO
  359. &label            _MIDISetPortName
  360. &label            _CallMIDIMgr midiSetPortName
  361.                   MEND
  362.  
  363.                   MACRO
  364. &label            _MIDIWakeUp
  365. &label            _CallMIDIMgr midiWakeUp
  366.                   MEND
  367.  
  368.                   MACRO
  369. &label            _MIDIRemovePort
  370. &label            _CallMIDIMgr midiRemovePort
  371.                   MEND
  372.  
  373.                   MACRO
  374. &label            _MIDIGetSync
  375. &label            _CallMIDIMgr midiGetSync
  376.                   MEND
  377.  
  378.  
  379.  
  380.  
  381.  
  382.                   MACRO
  383. &label            _MIDISetSync
  384. &label            _CallMIDIMgr midiSetSync
  385.                   MEND
  386.  
  387.                   MACRO
  388. &label            _MIDIGetCurTime
  389. &label            _CallMIDIMgr midiGetCurTime
  390.                   MEND
  391.  
  392.                   MACRO
  393. &label            _MIDISetCurTime
  394. &label            _CallMIDIMgr midiSetCurTime
  395.                   MEND
  396.  
  397.                   MACRO
  398. &label            _MIDIStartTime
  399. &label            _CallMIDIMgr midiStartTime
  400.                   MEND
  401.  
  402.                   MACRO
  403. &label            _MIDIStopTime
  404. &label            _CallMIDIMgr midiStopTime
  405.                   MEND
  406.  
  407.                   MACRO
  408. &label            _MIDIPoll
  409. &label            _CallMIDIMgr midiPoll
  410.                   MEND
  411.  
  412.                   MACRO
  413. &label            _MIDIWritePacket
  414. &label            _CallMIDIMgr midiWritePacket
  415.                   MEND
  416.  
  417.                   MACRO
  418. &label            _MIDIWorldChanged
  419. &label            _CallMIDIMgr midiWorldChanged
  420.                   MEND
  421.  
  422.                   MACRO
  423. &label            _MIDIGetOffsetTime
  424. &label            _CallMIDIMgr midiGetOffsetTime
  425.                   MEND
  426.  
  427.                   MACRO
  428. &label            _MIDISetOffsetTime
  429. &label            _CallMIDIMgr midiSetOffsetTime
  430.                   MEND
  431.  
  432.                   MACRO
  433. &label            _MIDIConvertTime
  434. &label            _CallMIDIMgr midiConvertTime
  435.                   MEND
  436.  
  437.                   MACRO
  438. &label            _MIDIGetRefCon
  439. &label            _CallMIDIMgr midiGetRefCon
  440.                   MEND
  441.  
  442.                   MACRO
  443. &label            _MIDISetRefCon
  444. &label            _CallMIDIMgr midiSetRefCon
  445.                   MEND
  446.  
  447.                   MACRO
  448. &label            _MIDIGetClRefCon
  449. &label            _CallMIDIMgr midiGetClRefCon
  450.                   MEND
  451.  
  452.                   MACRO
  453. &label            _MIDISetClRefCon
  454. &label            _CallMIDIMgr midiSetClRefCon
  455.                   MEND
  456.  
  457.                   MACRO
  458. &label            _MIDIGetTCFormat
  459. &label            _CallMIDIMgr midiGetTCFormat
  460.                   MEND
  461.  
  462.                   MACRO
  463. &label            _MIDISetTCFormat
  464. &label            _CallMIDIMgr midiSetTCFormat
  465.                   MEND
  466.  
  467.                   MACRO
  468. &label            _MIDISetRunRate
  469. &label            _CallMIDIMgr midiSetRunRate
  470.                   MEND
  471.  
  472.                   MACRO
  473. &label            _MIDIGetClientIcon
  474. &label            _CallMIDIMgr midiGetClientIcon
  475.                   MEND
  476.  
  477.  
  478.  
  479.     ENDIF    ; ...already included